package MineGod;

import org.lwjgl.opengl.GL11;
import org.newdawn.slick.opengl.Texture;

public abstract class Block {
	public double maxDurability;
	public double durability;
	public boolean obeyGravity;
	public boolean isLiquid;
	public boolean isSolid;
	public static final double WIDTH = 16;
	public double zIndex = 0;
	public final BlockType type;
	
	public Block(BlockType tempType){
		maxDurability = 100;
		durability = 100;
		obeyGravity = false;
		isLiquid = false;
		isSolid = true;
		type = tempType;
	}
	
	public void render(double x, double y){
		GL11.glTexParameteri(GL11.GL_TEXTURE_2D, GL11.GL_TEXTURE_MAG_FILTER, GL11.GL_NEAREST);
		GL11.glTexParameteri(GL11.GL_TEXTURE_2D, GL11.GL_TEXTURE_MAG_FILTER, GL11.GL_NEAREST);
		getTexture().bind();
		GL11.glColor3d((durability)/maxDurability, (durability)/maxDurability, (durability)/maxDurability); // Could make this faster!!
		GL11.glBegin(GL11.GL_QUADS);
			GL11.glNormal3d(0, 0, 1);
			GL11.glTexCoord2d(0.0, 0.0);
			GL11.glVertex3d(x, y, zIndex);
			GL11.glTexCoord2d(1.0, 0.0);
			GL11.glVertex3d(x + WIDTH, y, zIndex);
			GL11.glTexCoord2d(1.0, 1.0);
			GL11.glVertex3d(x + WIDTH, y + WIDTH, zIndex);
			GL11.glTexCoord2d(0.0, 1.0);
			GL11.glVertex3d(x, y + WIDTH, zIndex);
		GL11.glEnd();
	}
	
	public abstract Entity dropItem(double x, double y);
	
	public abstract Texture getTexture();

}
